import Mock from 'mockjs'

const Random = Mock.Random;
import {urlParams2Obj} from '@/utils/index.js'
//生成模拟数据：按月汇总订单金额、数量
let orderSumByMonth = [];
for (let i = 1; i <= 12; i++) {
  orderSumByMonth.push({
    month: (i + '').padStart(2, '0'),	//'01'、'02'、'03'...
    amount: Random.integer(20000, 50000),
    count: Random.integer(10, 20),
  });
}

// 生成模拟API接口
Mock.mock(new RegExp('/home/echars/orderSumByMonth'), 'get', options => {
  const {url} = options;
  const query = urlParams2Obj(url);
  const {year} = query;
  const result = {
    code: 1,
    msg: "成功获取:" + year,
    data: orderSumByMonth
  }
  return result;
});
